package org.shagin.jfin.data.model;

import org.shagin.jfin.data.Money;

/**
 * The Class Account.
 */
public class Account extends AbstractBudgetItem {

    private CostCenter costCenter;
    private Money amount;

    /**
     * Instantiates a new account.
     * 
     * @param accountId the account id
     * @param costCenter the cost center
     * @param amount the amount
     */
    public Account(String accountId, CostCenter costCenter, Money amount,
            IBudget budget) {
        super(accountId);
        if (costCenter == null)
            throw new IllegalArgumentException("costCenter is null");
        if (amount == null)
            throw new IllegalArgumentException("amount is null");
        if (budget == null)
            throw new IllegalArgumentException("budget is null");
        this.costCenter = costCenter;
        this.amount = amount;
        this.costCenter.getAccounts().add(this);
        this.budget = budget;
    }
    /**
     * {@inheritDoc}
     */
    public CostCenter getCostCenter() {
        return costCenter;
    }

    /**
     * Sets the cost center.
     * 
     * @param costCenter the new cost center
     */
    void setCostCenter(CostCenter costCenter) {
        this.costCenter = costCenter;
    }

    /**
     * {@inheritDoc}
     */
    public Money getAmount() {
        return amount;
    }

    /**
     * {@inheritDoc}
     */
    public void setAmount(Money amount) {
        this.amount = amount;
    }
}
